﻿using Basic.FlowApplication.Extend;
using Basic.FlowApplication.Interface;
using Basic.FlowApplication.Model;
using Basic.FlowApplication.Model.AuditLog;
using Basic.FlowRemoteModel;
using Basic.FlowRemoteModel.Application.Model;
using WeDonekRpc.Client.Attr;

namespace Basic.FlowApplication.AuditEvent
{
    [IocName("Audit_10")]
    [ClassLifetimeAttr(ClassLifetimeType.SingleInstance)]
    internal class EnableAuditEvent : IItemAuditEvent
    {
        public AfootAuditLogItem ItemAudit ( AuditFlowBody flow, FlowAuditLogState log, AuditRes result )
        {
            AfootAuditLogItem item = log.LogItem.Find(a => a.Id == result.ItemId);
            item.CheckAuditItem(result, FlowAuditItemStatus.待开始);
            item.AuditState = FlowAuditItemStatus.审核进行中;
            FlowNode node = flow.Nodes[item.NodeId];
            if ( node.LimitTime.HasValue )
            {
                item.TimeOut = DateTime.Now.AddMinutes(node.LimitTime.Value);
            }
            return item;
        }
    }
}
